<?php

namespace IMT\UserBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;


class UserController extends Controller
{
    
    public function editAction()
    {
    	$user = $this->container->get('security.context')->getToken()->getUser();

        $form = $this->container->get('fos_user.profile.form');
        $formHandler = $this->container->get('fos_user.profile.form.handler');

        $process = $formHandler->process($user);
        if ($process) {
            $this->get('session')->setFlash('success', 'Le profil a été modifié !');

            return $this->redirect($this->generateUrl('profil_user_edit'));
        }
        
        return $this->container->get('templating')->renderResponse(
            'IMTUserBundle:Profile:edit.html.'.$this->container->getParameter('fos_user.template.engine'),
            array('form' => $form->createView(), 'theme' => $this->container->getParameter('fos_user.template.theme'))
        );
    }
}
